package cn.kgc.controller;

import cn.kgc.dto.ResultInfo;
import cn.kgc.pojo.Contact;
import cn.kgc.service.ContactService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@Api(tags = "根据id查询")
@RequestMapping("/GetById")
public class GetByIdController {
    @Resource
    private ContactService contactService;
    @ApiOperation("根据id查询")
    @ApiImplicitParam(name = "id",value = "id",required = true)

    @GetMapping(value = "getContactById")
    public ResultInfo getById(int id){
        try{
            return new ResultInfo(200,"根据id查询成功",contactService.findContactById(id));
        }catch (Exception e){
            return new ResultInfo(200,"根据id查询成功",null);
        }
    }
}
